package com.spatio.serving.basic.service.template.core.component.redission;

import com.spatio.serving.common.lib.common.enums.EnvironmentEnum;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;

import java.io.IOException;

public class RedissonHolder {

    private static RedissonClient redissonClient;

    public static void init(EnvironmentEnum env) throws IOException {
        Config config = Config.fromYAML(RedissonHolder.class.getClassLoader().getResourceAsStream("redisson/redisson-" + env.getEnv() + ".yml"));
        redissonClient = Redisson.create(config);
    }

    public static RedissonClient getInstance() {
        return redissonClient;
    }
}